var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderList: [{
      id: "1",
      title: "1",
      name: "1",
      price: "1",
      count: "1",
      number: "1",
      total: "1",
     
    }]
  },


  myRequest:function(){
    var that = this
    wx.getStorage({
      key: 'openid',
      success: function (res) {
        let openid = res.data
        wx.showLoading({
          title: '加载中',
        })
        wx.request({
          url: app.globalData.URL + '/app/team/orderList?orderState=4&openid=' + openid,
          success: function (res) {
            wx.hideLoading()
            console.log("remarks:", res.data.remarks)
            that.setData({
              orderList: res.data.orderList
            })

          }
        })
      },
    })
  },

  onShow:function(){
    this.myRequest()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  sendGoods: function (e) {  
    console.log("e:",e)
    var that = this
    wx.getStorage({
      key: 'openid',
      success: function (res) {
        let openid = res.data

        wx.request({
          url: app.globalData.URL + '/app/memberCard/cardNumMeet?openid=' + openid + '&orderNum=' + e.currentTarget.dataset.id,
          success: function (res) {
            console.log("cardNumMeet:", res.data)
            
            if(res.data.flag == true){
              wx.request({
                url: app.globalData.URL + '/app/awardLogic/qdfh?openid=' + openid + '&orderNum=' + e.currentTarget.dataset.id,
                success:function(res){
                  console.log("qdfh:", res.data)
                  if(res.data.flag == true){
                    wx.showToast({
                      title: '确认成功',
                      success:function(){
                        that.myRequest()
                      }
                    })
                  }
                }
              })
            }else{
              wx.showModal({
                title: '',
                content: res.data.msg,
              })
            }
          }
        })
      },
    })
  },





})